﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModifyWillCustomer.aspx.cs" Inherits="ZX.WebApp.Crm.Customer.ModifyWillCustomer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/extend.validate.js" type="text/javascript"></script>
</head>
<body class="yui-skin-sam" onkeydown="PreventBSK()">
    <form id="form1" runat="server">
    <div>
        <div id="content">
            <table style="width:100%; margin-top:40px;" class="table1">
                <tr>
                    <td colspan="2" style=" text-align:center; font-weight:bold;">
                        转意向
                    </td>
                </tr>
                <tr>
                    <td style="width:100px;">
                        类型
                    </td>
                    <td>
                        <select id="WillType" style="width:200px;">
                            <option value=""></option>
                            <option value="0">转本人</option>
                            <option value="1">转他人</option>
                        </select>
                        <span style="color:Red;">*</span>
                    </td>
                </tr>
                <tr class="trType">
                    <td>
                        选择人员
                    </td>
                    <td>
                        <input type="hidden" id="UserID" name="UserID" runat="server" />
                        <input id="txtUserID" name="txtUserID" type="text" runat="server" readonly="readonly" value="" style="width:200px;" />
                        <button id="btnUserID" name="V" runat="server" type="button" value="" class="yui-button yui-push-button">
                            选择</button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
<script type="text/javascript">
    var currentUserId = "<%=CurrentUserID %>", CustomerId = "<%=CustomerID %>";
    $(document).ready(function () {
        $("#WillType").change(function () {
            var vType = $(this).children('option:selected').val();
            if (vType == 1) { //转他人
                $(".trType").show();
            } else {
                $(".trType").hide();
            }
        });
    });
    //保存数据
    function Save() {
        var _type = $("#WillType").val();
        var _userid = $("#UserID").val();
        if (_type == "") {
            alert("请选择类型!");
            $("#WillType").focus();
            return;
        }
        if (_type == 1) { //转他人
            if (_userid == "" || _userid == "") {
                alert("请选择人员!");
                $("#txtUserID").focus();
                return;
            }
        } else {
            _userid = currentUserId;
        }
        if (confirm("是否确定将该客户转为意向客户?")) {
            var SaveUrl = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=procedure&entity=CrmWillCustomers&json=&id=" + CustomerId + "&uId=" + _userid;
            YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "1") {
                            alert("转为意向客户成功!");
                            parent.YAHOO.example.container.dialog1.hide();
                        } else {
                            alert(str);
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    }
</script>
</html>
